﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;

namespace WebSite.admin.member
{
    public partial class account_log_add : BaseAdmin
    {
  
        public string score1 = "0";

        public string score3 = "0";


        // Methods
        private void Bind()
        {
            string sql = "select score1,score3 from DB_Member where memberid=" + base.Request.QueryString["mid"].ToString() + " and isnull(flag,0)!=2";
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];
            this.score1 = table.Rows[0]["score1"].ToString();
            this.score3 = table.Rows[0]["score3"].ToString();
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (base.Request.QueryString["mid"] != null)
            {
                string str3 = "0";
                string str4 = "0";
                string str5 = "0";
                if (this.add3.Value.ToString() == "1")
                {
                    str5 = "-" + this.kscore1.Value.ToString();
                    if ((Convert.ToInt16(this.score1) - Convert.ToInt16(this.kscore1.Value)) < 0)
                    {
                        str3 = "0";
                    }
                    else
                    {
                        str3 = (Convert.ToInt16(this.score1) - Convert.ToInt16(this.kscore1.Value)) + "";
                    }
                    if ((Convert.ToInt16(this.score3) - Convert.ToInt16(this.kscore1.Value)) < 0)
                    {
                        str4 = "0";
                    }
                    else
                    {
                        str4 = (Convert.ToInt16(this.score3) - Convert.ToInt16(this.kscore1.Value)) + "";
                    }
                }
                else
                {
                    str5 = "＋" + this.kscore1.Value.ToString();
                    str3 = (Convert.ToInt16(this.score1) + Convert.ToInt16(this.kscore1.Value)) + "";
                    str4 = (Convert.ToInt16(this.score3) + Convert.ToInt16(this.kscore1.Value)) + "";
                }
                SQLAccess.DoSql(string.Concat(new object[] { "insert into DB_Score (memberid,scorename,scoreprice,content,updatetime,scoretype) values (", base.Request.QueryString["mid"].ToString(), ",'", re.replace(this.scorename.Text), "','", str5, "','", re.replace(this.TextBox1.Text), "','", DateTime.Now, "',", this.add3.Value.ToString(), ")" }));
                SQLAccess.DoSql("update DB_Member set score1=" + str3 + ",score3=" + str4 + " where memberid=" + base.Request.QueryString["mid"].ToString() + "");
                base.Response.Write("<script language='javascript'>alert('调节成功！');window.location.href='account_log.aspx?mid=" + base.Request.QueryString["mid"].ToString() + "';</script>");
                base.Response.End();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack && (base.Request.QueryString["mid"] != null))
            {
                this.Bind();
            }
        }


    }
}